<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php /** @var $this \Magento\Sales\Block\Adminhtml\Order\View\Info */ ?>
<?php $_order = $this->getOrder() ?>
<?php
$orderAdminDate = $this->formatDate($_order->getCreatedAtDate(), 'medium', true);
$orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
?>

<?php /* the opening and closing divs of these two clearfixes are in app\code\core\Mage\Adminhtml\view\adminhtml\sales\order\invoice\create\form.phtml */?>

<div class="clearfix">

    <div class="order-information">
        <?php /* Order Information */?>
        <div class="fieldset-wrapper">
            <?php if ($_order->getEmailSent()):
                $_email = __('the order confirmation email was sent');
            else:
                $_email = __('the order confirmation email is not sent');
            endif; ?>
            <div class="fieldset-wrapper-title">
                <span class="title">
                    <?php if ($this->getNoUseOrderLink()): ?>
                    <?php echo __('Order # %1', $_order->getRealOrderId()) ?> (<span><?php echo $_email ?></span>)
                    <?php else: ?>
                    <a href="<?php echo $this->getViewUrl($_order->getId()) ?>"><?php echo __('Order # %1', $_order->getRealOrderId()) ?></a>
                    <span>(<?php echo $_email ?>)</span>
                    <?php endif; ?>
                </span>
            </div>
            <table cellspacing="0" class="data-table">
                <tr>
                    <th><?php echo __('Order Date') ?></th>
                    <td><?php echo $orderAdminDate ?></td>
                </tr>
                <?php if ($orderAdminDate != $orderStoreDate):?>
                <tr>
                    <th><?php echo __('Order Date (%1)', $_order->getCreatedAtStoreDate()->getTimezone()) ?></th>
                    <td><?php echo $orderStoreDate ?></td>
                </tr>
                <?php endif;?>
                <tr>
                    <th><?php echo __('Order Status') ?></th>
                    <td><span id="order_status"><?php echo $_order->getStatusLabel() ?></span></td>
                </tr>
                <?php if ($this->isSingleStoreMode() == false):?>
                <tr>
                    <th><?php echo __('Purchased From') ?></th>
                    <td><?php echo $this->getOrderStoreName() ?></td>
                </tr>
                <?php endif; ?>
                <?php if($_order->getRelationChildId()): ?>
                <tr>
                    <th><?php echo __('Link to the New Order') ?></th>
                    <td><a href="<?php echo $this->getViewUrl($_order->getRelationChildId()) ?>">
                        <?php echo $_order->getRelationChildRealId() ?>
                    </a></td>
                </tr>
                <?php endif; ?>
                <?php if($_order->getRelationParentId()): ?>
                <tr>
                    <th><?php echo __('Link to the Previous Order') ?></th>
                    <td><a href="<?php echo $this->getViewUrl($_order->getRelationParentId()) ?>">
                        <?php echo $_order->getRelationParentRealId() ?>
                    </a></td>
                </tr>
                <?php endif; ?>
                <?php if($_order->getRemoteIp() && $this->shouldDisplayCustomerIp()): ?>
                <tr>
                    <th><?php echo __('Placed from IP') ?></th>
                    <td><?php echo $_order->getRemoteIp(); echo ($_order->getXForwardedFor())?' (' . $this->escapeHtml($_order->getXForwardedFor()) . ')':''; ?></td>
                </tr>
                <?php endif; ?>
                <?php if($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>
                <tr>
                    <th><?php echo __('%1 / %2 rate:', $_order->getGlobalCurrencyCode(), $_order->getBaseCurrencyCode()) ?></th>
                    <td><?php echo $_order->getBaseToGlobalRate() ?></td>
                </tr>
                <?php endif; ?>
                <?php if($_order->getBaseCurrencyCode() != $_order->getOrderCurrencyCode()): ?>
                <tr>
                    <th><?php echo __('%1 / %2 rate:', $_order->getOrderCurrencyCode(), $_order->getBaseCurrencyCode()) ?></th>
                    <th><?php echo $_order->getBaseToOrderRate() ?></th>
                </tr>
                <?php endif; ?>
            </table>
        </div>
    </div>

    <div class="order-account-information">
        <?php /* Account Information */?>
        <div class="fieldset-wrapper">
            <div class="fieldset-wrapper-title">
                <div class="actions"><?php echo $this->getAccountEditLink()?></div>
                <span class="title"><?php echo __('Account Information') ?></span>
            </div>
            <table cellspacing="0" class="data-table">
                <tr>
                    <th><?php echo __('Customer Name') ?></th>
                    <td>
                    <?php if ($_customerUrl=$this->getCustomerViewUrl()) : ?>
                        <a href="<?php echo $_customerUrl ?>" target="_blank"><strong><?php echo $this->escapeHtml($_order->getCustomerName()) ?></strong></a>
                    <?php else: ?>
                        <?php echo $this->escapeHtml($_order->getCustomerName()) ?>
                    <?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo __('Email') ?></th>
                    <td><a href="mailto:<?php echo $_order->getCustomerEmail() ?>"><?php echo $_order->getCustomerEmail() ?></a></td>
                </tr>
                <?php if ($_groupName = $this->getCustomerGroupName()) : ?>
                <tr>
                    <th><?php echo __('Customer Group') ?></th>
                    <td><?php echo $_groupName ?></td>
                </tr>
                <?php endif; ?>
                <?php foreach ($this->getCustomerAccountData() as $data):?>
                <tr>
                    <th><?php echo $data['label'] ?></th>
                    <td><?php echo $data['value'] ?></td>
                </tr>
                <?php endforeach;?>
            </table>
        </div>
    </div>

</div>

<div class="clearfix">

    <div class="order-billing-address">
        <?php /* Billing Address */?>
        <div class="fieldset-wrapper">
            <div class="fieldset-wrapper-title">
                <div class="actions"><?php echo $this->getAddressEditLink($_order->getBillingAddress()); ?></div>
                <span class="title"><?php echo __('Billing Address') ?></span>
            </div>
            <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
        </div>
    </div>

    <?php if (!$this->getOrder()->getIsVirtual()): ?>
    <div class="order-shipping-address">
        <?php /* Shipping Address */ ?>
        <div class="fieldset-wrapper">
            <div class="fieldset-wrapper-title">
                <div class="actions"><?php echo $this->getAddressEditLink($_order->getShippingAddress()); ?></div>
                <span class="title"><?php echo __('Shipping Address') ?></span>
            </div>
            <address><?php echo $_order->getShippingAddress()->format('html') ?></address>
        </div>
    </div>
</div>
    <?php endif; ?>

<?php
/*
    closing div of this opening div are in
    app\code\Magento\Sales\view\adminhtml\order\invoice\view\form.phtml
    or
    app\code\Magento\Sales\view\adminhtml\order\view\tab\info.phtml
*/
?>
